package com.base.saas.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
/**
 * @author 王清亮
 */
@SpringBootApplication
public class SaasGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(SaasGatewayApplication.class, args);

    }

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("trade_route", r -> r.path("/trade/**")
                        .filters(f -> f.stripPrefix(1)) .uri("lb://saas-trade"))
                .route("delivery_route", r -> r.path("/delivery/**")
                        .filters(f -> f.stripPrefix(1)) .uri("lb://saas-delivery"))
                .build();
    }




}
